package example;

/**
 * MyArrayList.class
 *
 * @author tingwen
 * @date date
 */
public class MyArrayList<T> implements MyList<T> {
    int initialCapacity = 8;

    private Object[] elementData = {};

    private int size;

    void rangeCheck(int index) {
        if (index > size) {
            throw new ArrayIndexOutOfBoundsException();
        }
    }

    @Override
    public boolean add(T t) {
        elementData[size++] = t;
        return false;
    }

    @Override
    public void add(int index, T t) {
        rangeCheck(index);
        elementData[index] = t;
    }

    @Override
    public boolean remove(Object t) {

        return false;
    }

    @Override
    public void remove(int index) {

    }

    @Override
    public boolean contain(T t) {
        return false;
    }

    @Override
    public int union(MyList<T> myList) {
        return 0;
    }

    @Override
    public T get(int index) {
        rangeCheck(index);
        return (T) elementData[index];
    }

    @Override
    public int size() {
        return size;
    }
}
